﻿using System;
using System.Windows.Forms;
using Assist;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;

namespace YJKAxisAndEdit
{
	[Transaction(TransactionMode.Manual)]
	[Regeneration(RegenerationOption.Manual)]
	public class CmdRenameAxis : YJKCommandAuto
	{
		protected override Result YJKExcute(ExternalCommandData cmdData, ref string message, ElementSet elements)
		{
			Document document = cmdData.Application.ActiveUIDocument.Document;
            if (2 != (int)document.ActiveView.ViewType && 1 != (int)document.ActiveView.ViewType)
			{
				MessageBox.Show("请在平面视图中运行。", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
				return Autodesk.Revit.UI.Result.Cancelled;
			}
			RenameAxis renameAxis = new RenameAxis(cmdData);
			Result result;
			do
			{
				result = renameAxis.Rename(ref message);
			}
			while (result == Autodesk.Revit.UI.Result.Succeeded);
			return Autodesk.Revit.UI.Result.Succeeded;
		}
	}
}
